﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test2014.aspx.cs" Inherits="CRMWeb.Pages.Report.Test2014" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link rel="stylesheet" id="newtheme" type="text/css" href="/EasyUI/Themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="/EasyUI/Themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="/Css/CrmStyle.css" />
    <script type="text/javascript" src="/Scripts/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="/EasyUI/jquery.easyui.min.js"></script>
</head>

<body>
    <form id="form1" runat="server">
        <div class="ftitle" style="text-align: center">Report Test 2014 </div>
        <div class="fitem" style="text-align: center; padding: 5px">
            <span>
                <label>Data Source :</label>
                <input id="cmbComesFrom" class="easyui-combobox" style="width: 120px;" data-options="panelHeight:'auto',
                    url:'/WebServices/ApplicationInfo.ashx?method=GetDistinctComesFrom',
                    valueField: 'comesfrom',  
                    textField: 'comesfrom',
                    onLoadSuccess:function(){
                     $('#cmbComesFrom').combobox('setValue', 'ALL');
                    }" />
            </span>

            <span>
                <label>State :</label>
                <select id="cmbState" data-options="panelHeight:'auto',
			        validType:'inList[\'#cmbState\']',
			        filter: function(q,row){
			        return row.text.toLowerCase().indexOf(q.toLowerCase())==0;}"
                    style="width: 90px;" class="easyui-combobox">
                    <option value="NSW">NSW</option>
                    <option value="QLD">QLD</option>
                    <option value="VIC">VIC</option>
                    <option value="SA">SA</option>
                    <option value="WA">WA</option>
                    <option value="TAS">TAS</option>
                    <option value="ACT">ACT</option>
                    <option value="NT">NT</option>
                </select>
            </span>

            <span>
                <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="LoadReport()">Confirm</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="exportToCSV()">Export To CSV</a>
            </span>

        </div>

        <div class="fitem" id="reportTest2014Grid">
            <table id="dgTestReport" title="Report - Test 2014" style="width: auto;" autorowheight="true" rownumbers="true" fitcolumns="true" singleselect="true" pagination="true" data-options="pageSize:20">
                <thead>
                    <tr>
                        <th field="ContactID" width="25" sortable="true">Contact ID</th>
                        <th field="FirstName" width="30" sortable="true">First Name</th>
                        <th field="SurName" width="30" sortable="true">Surname</th>
                        <th field="Email" width="50" sortable="true">Email</th>
                        <th field="Mobile" width="30" sortable="true">Mobile</th>
                        <th field="State" width="15" sortable="true">State</th>
                        <th field="PurposeSummary" width="25" sortable="true">Purpose</th>
                        <th field="CreateDate" width="45" sortable="true">CreateDate</th>
                    </tr>
                </thead>
            </table>
        </div>

    </form>

    <script type="text/javascript">

        $(document).ready(function () {
            $('#dgTestReport').datagrid({
                url: '/WebServices/Report/Report.ashx?method=GetTestReport2014&strState=NSW&comesfrom=ALL'
            });
        });


        function LoadReport() {
            $('#dgTestReport').datagrid({
                url: '/WebServices/Report/Report.ashx?method=GetTestReport2014&strState=' + $('#cmbState').combobox('getValue') + '&comesfrom=' + $('#cmbComesFrom').combobox('getValue')
            });
        }

        function exportToCSV() {
            var iframe = document.createElement("iframe");
            iframe.src = encodeURI('/WebServices/Report/ExportToCSV.ashx?strState=' + $('#cmbState').combobox('getValue') + '&strcomesfrom=' + $('#cmbComesFrom').combobox('getValue') + '&strReport=Test2014');
            iframe.style.display = "none";
            document.body.appendChild(iframe);
        }

    </script>
</body>
</html>
